import cv2

img = cv2.imread('F:\\P_005.jpg')
img2 = cv2.cvtColor(img,cv2.COLOR_BGR2GRAY)
# 二值化古籍黑白化
dts = cv2.adaptiveThreshold(img2,110,cv2.ADAPTIVE_THRESH_GAUSSIAN_C,cv2.THRESH_BINARY,9,0)

cv2.imshow('img',img)
cv2.imshow('img2',img2)
cv2.imshow('dts',dts)
#cv2.imwrite('adaptive.jpg', dts)
cv2.waitKey(0)